import Vue from 'vue'
import Router from 'vue-router'
import login from '@/components/login'
import home from '@/components/home'
import page from '@/components/page/page'

Vue.use(Router)
// 定义路由配置
const router = new Router({
  routes: [{
      path: '/',
      name: 'login',
      component: login
    },
    {
      path: '/home',
      name: 'home',
      component: home,
      children: [
				{
				  name: 'default',
				  path: '/default',
				  component: () => import('@/components/default/default')
				},
				{
          name: 'module',
          path: '/module',
          component: () => import('@/components/module/module')
        },
        {
          name: 'moduleitem',
          path: '/moduleitem',
          component: () => import('@/components/module/moduleitem')
        },
				{
				  name: 'rolelist',
				  path: '/rolelist',
				  component: () => import('@/components/module/rolelist')
				},
        {
          name: 'systemaccount',
          path: '/systemaccount',
          component: () => import('@/components/module/systemaccount')
        },
        {
          name: 'admin_setting',
          path: '/admin_setting',
          component: () => import('@/components/administrator/administrator')
        },
        {
          name: 'companylist',
          path: '/companylist',
          component: () => import('@/components/company/companylist')
        },
				{
				  name: 'companyadmin',
				  path: '/companyadmin',
				  component: () => import('@/components/company/companyadmin')
				},
				
        {
          name: 'memberlist',
          path: '/memberlist',
          component: () => import('@/components/member/memberlist')
        },
				{
				  name: 'memberadmin',
				  path: '/memberadmin',
				  component: () => import('@/components/member/memberadmin')
				},
        {
          name: 'basicsetting',
          path: '/basicsetting',
          component: () => import('@/components/basicadmin/basicadmin')
        }
      ],
    },
    {
      path: '/page/page',
      name: 'page',
      component: page
    }
  ]
})

// 全局路由拦截-进入页面前执行
router.beforeEach((to, from, next) => {
    // 这里可以加入全局登陆判断
    // 继续执行
    next();
});

// 全局后置钩子-常用于结束动画等
router.afterEach(() => {
    //不接受next
});

export default router;
